# import sqlite3

# DB_PATH = "data/journals.db"

# conn = sqlite3.connect(DB_PATH)
# cursor = conn.cursor()

# # 检查是否已存在 username 字段
# cursor.execute("PRAGMA table_info(journals);")
# columns = [col[1] for col in cursor.fetchall()]
# if "username" not in columns:
#     cursor.execute("ALTER TABLE journals ADD COLUMN username TEXT;")
#     print("已添加 username 字段")
# else:
#     print("username 字段已存在")

# conn.commit()
# conn.close()

# import os
# print(os.path.abspath("data/journals.db"))


# import sqlite3
# conn = sqlite3.connect("data/journals.db")
# cursor = conn.cursor()
# cursor.execute("PRAGMA table_info(journals);")
# print(cursor.fetchall())
# conn.close()

import sqlite3
conn = sqlite3.connect('backend/data/journals.db')
cursor = conn.cursor()
cursor.execute("ALTER TABLE journals ADD COLUMN type TEXT DEFAULT 'diary';")
conn.commit()
conn.close()